using System.Text;
using MauiApp.Models;
using MauiApp.Service;

namespace TestMauiApiFix
{
    class Program
    {
        static async Task Main(string[] args)
        {
            try
            {
                Console.WriteLine("测试修复后的MauiApp AddFileAsync方法...");
                
                // 创建测试数据，模拟MauiApp中的调用场景
                var timeStampModel = new TimeStampModel
                {
                    FileName = "测试文件.txt",
                    FilePath = "test/path/test.txt",
                    TypeID = 1,
                    Time = DateTime.Now,
                    OpenTime = DateTime.Now,
                    FTPPath = "ftp/test/path/test.txt",
                    UserId = "123" // 模拟App.CurrentUserId，这里使用可转换为int的字符串
                };
                
                // 创建ApiService实例
                var apiService = new ApiService();
                
                // 调用AddFileAsync方法
                Console.WriteLine($"发送请求，UserId为: {timeStampModel.UserId}");
                var result = await apiService.AddFileAsync(timeStampModel);
                
                // 输出结果
                if (result)
                {
                    Console.WriteLine("✅ 测试成功！AddFileAsync方法调用成功。");
                }
                else
                {
                    Console.WriteLine("❌ 测试失败！AddFileAsync方法调用失败。");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"发生异常: {ex.Message}");
                Console.WriteLine(ex.StackTrace);
            }
            
            Console.WriteLine("按任意键退出...");
            Console.ReadKey();
        }
    }
}